package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.dto.AddLivePkDto;
import com.cssw.fyzb.wap.model.dto.UpdateStatusByIdDto;
import com.cssw.fyzb.wap.model.vo.CreateLivePkVo;
import com.cssw.fyzb.wap.model.vo.LiveFriendVo;
import com.cssw.fyzb.wap.service.LivePkService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wondream
 */
@RestController
@RequestMapping("/livePk")
public class LivePkController {

    @Autowired
    LivePkService livePkService;

    @ApiOperation("同城匹配PK")
    @PostMapping("sameCityMatch")
    public AjaxData sameCityMatch() {
        return livePkService.sameCityMatch(UserContext.getUserId());
    }

    @ApiOperation("全国匹配PK")
    @PostMapping("nationwideMatch")
    public AjaxData nationwideMatch() {
        return livePkService.nationwideMatch(UserContext.getUserId());
    }

    @ApiOperation("查询直播好友列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从0开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @GetMapping("listLiveFriend")
    public AjaxPage<LiveFriendVo> listLiveFriend(Integer pageNumber, Integer pageSize) {
        return livePkService.listLiveFriend(UserContext.getUserId(), pageNumber, pageSize);
    }

    @ApiOperation("发起直播PK")
    @ApiImplicitParam(name = "dto", value = "发起直播PK", dataType = "AddLivePkDto")
    @PostMapping("addLivePk")
    public AjaxData<CreateLivePkVo> addLivePk(@RequestBody AddLivePkDto dto) {
        return livePkService.addLivePk(UserContext.getUserId(), dto.getFromLiveId(), dto.getToLiveId());
    }

    @ApiOperation("关闭直播PK")
    @ApiImplicitParam(name = "dto", value = "关闭直播PK", dataType = "UpdateStatusByIdDto")
    @PostMapping("closeLivePk")
    public AjaxData closeLivePk(@RequestBody UpdateStatusByIdDto dto) {
        return livePkService.closeLivePk(UserContext.getUserId(), dto.getPkId());
    }
}
